package com.ruoyi.fee.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.fee.domain.WWarehouseFeeRule;
import com.ruoyi.fee.service.IWWarehouseFeeRuleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 仓储费Controller
 * 
 * @author wzy
 * @date 2024-08-30 11:22:51
 */
@RestController
@RequestMapping("/fees/warehouse")
public class WWarehouseFeeRuleController extends BaseController
{
    @Autowired
    private IWWarehouseFeeRuleService wWarehouseFeeRuleService;

    /**
     * 查询仓储费列表
     */
    @PreAuthorize("@ss.hasPermi('fees:warehouse:list')")
    @GetMapping("/list")
    public TableDataInfo list(WWarehouseFeeRule wWarehouseFeeRule)
    {
        startPage();
        List<WWarehouseFeeRule> list = wWarehouseFeeRuleService.selectWWarehouseFeeRuleList(wWarehouseFeeRule);
        return getDataTable(list);
    }

    /**
     * 导出仓储费列表
     */
    @PreAuthorize("@ss.hasPermi('fees:warehouse:export')")
    @Log(title = "仓储费", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WWarehouseFeeRule wWarehouseFeeRule)
    {
        List<WWarehouseFeeRule> list = wWarehouseFeeRuleService.selectWWarehouseFeeRuleList(wWarehouseFeeRule);
        ExcelUtil<WWarehouseFeeRule> util = new ExcelUtil<WWarehouseFeeRule>(WWarehouseFeeRule.class);
        util.exportExcel(response, list, "仓储费数据");
    }

    /**
     * 获取仓储费详细信息
     */
    @PreAuthorize("@ss.hasPermi('fees:warehouse:query')")
    @GetMapping(value = "/{warehouseFeeId}")
    public AjaxResult getInfo(@PathVariable("warehouseFeeId") Long warehouseFeeId)
    {
        return success(wWarehouseFeeRuleService.selectWWarehouseFeeRuleByWarehouseFeeId(warehouseFeeId));
    }

    /**
     * 新增仓储费
     */
    @PreAuthorize("@ss.hasPermi('fees:warehouse:add')")
    @Log(title = "仓储费", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WWarehouseFeeRule wWarehouseFeeRule)
    {
        wWarehouseFeeRule.setCreateBy(getNickName());
        return toAjax(wWarehouseFeeRuleService.insertWWarehouseFeeRule(wWarehouseFeeRule));
    }

    /**
     * 修改仓储费
     */
    @PreAuthorize("@ss.hasPermi('fees:warehouse:edit')")
    @Log(title = "仓储费", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WWarehouseFeeRule wWarehouseFeeRule)
    {
        wWarehouseFeeRule.setUpdateBy(getNickName());
        return toAjax(wWarehouseFeeRuleService.updateWWarehouseFeeRule(wWarehouseFeeRule));
    }

    /**
     * 删除仓储费
     */
    @PreAuthorize("@ss.hasPermi('fees:warehouse:remove')")
    @Log(title = "仓储费", businessType = BusinessType.DELETE)
	@DeleteMapping("/{warehouseFeeIds}")
    public AjaxResult remove(@PathVariable Long[] warehouseFeeIds)
    {
        return toAjax(wWarehouseFeeRuleService.deleteWWarehouseFeeRuleByWarehouseFeeIds(warehouseFeeIds));
    }
}
